package com.itheima.health.mapper;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author spt
 * @description 套餐DAO
 **/
@Mapper
public interface SetMealMapper {
    /**
     * 插入
     * @param setmeal
     */
    void insert(Setmeal setmeal);

    /**
     * 插入与检查组关联关系
     * @param setmealId
     * @param checkgroupId
     */
    void insertSetMealAndCheckGroup(@Param("setmealId") Integer setmealId, @Param("checkgroupId") Integer checkgroupId);

    /**
     * 根据条件分页查询
     * @param queryString
     * @return
     */
    Page<Setmeal> selectByCondition(@Param("queryString") String queryString);

    /**
     * 查询图片是否存在
     * @param x
     * @return
     */
    @Select("select count(*) from t_setmeal where img like concat('%', #{x}, '%')")
    int countByImageName(String x);

    /**
     * 查询所有图片
     * @return
     */
    @Select("select img from t_setmeal")
    Set<String> selectImageName();

    /**
     * 查询全部套餐
     * @return
     */
    @Select("select * from t_setmeal")
    List<Setmeal> findAll();

    /**
     * 根据id查询套餐
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where id = #{id}")
    Setmeal findById(Integer id);
}
